#pragma once
#include "Socket.h"
#include "Channel.h"
#include "EventLoop.h"
#include "Connection.h"

class Acceptor
{
private:
    EventLoop* m_loop;
    Socket m_servsock;
    Channel m_acceptchannel;

    std::function<void(std::unique_ptr<Socket>)> m_new_conneciton_cb;
public:
    Acceptor(EventLoop* loop,const char* ip,uint16_t port);
    ~Acceptor();

    void new_connection();
    void set_callback(std::function<void(std::unique_ptr<Socket>)> fn);
};
